/*
 * @Author: doing
 * @Date: 2023-08-23 07:40:02
 * @LastEditors: git config user.name && git config user.email
 * @LastEditTime: 2023-08-26 13:50:50
 * @FilePath: \authentication-center\src\api\auth.js
 * @Description: 
 * 权限管理接口
 * Copyright (c) 2023 by 1540265624@qq.com, All Rights Reserved. 
 */
import axios from '~/utils/request'

// 数据格式
const headers = { 'Content-Type': 'application/x-www-form-urlencoded' }

// 请求头添加 Authorization: Basic client_id:client_secret
const Auth = { 
    username: 'xssn-admin', // client_id
    password: '123456' // client_secret
}

//登录接口
export function login(data) {
    return axios.post('/auth/login',
    data,
      {
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            'Authorization': 'Basic ' + btoa(`${Auth.username}:${Auth.password}`)
        }
      }
    );
  }
  

//注册接口
export function register(){
    return axios.post('/system/api/user/register')
}

//查询用户是否已经被注册
export function isRegister(username){
    return axios.get(`/system/api/user/username/${username}`)
}

//刷新令牌接口
export function updataToken(){
    return axios.get('/auth/user/refreshToken')
}
